package com.example.demo.Bean;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

@Data
public class Experiment implements Serializable {

    @TableId(type = IdType.AUTO)
    private Integer experimentId;

    private String courseId;

    private String name;

    private Integer draftId;

    @DateTimeFormat(pattern = "yyyy-MM-dd' 'HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd' 'HH:mm:ss")
    private Date beginTime;

    @DateTimeFormat(pattern = "yyyy-MM-dd' 'HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd' 'HH:mm:ss")
    private Date endTime;

    private String path;

    @TableField(exist = false)
    private List<String> pathList = new ArrayList<>();

    private String content;

    @TableField(fill = FieldFill.INSERT)
    @DateTimeFormat(pattern = "yyyy-MM-dd' 'HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd' 'HH:mm:ss")
    private Date createTime;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @DateTimeFormat(pattern = "yyyy-MM-dd' 'HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd' 'HH:mm:ss")
    private Date updateTime;

    @TableLogic
    private Integer isDelete;

    public void setPath(String path){
        this.path = path;
        this.pathList = Arrays.asList(path.split(";"));
    }

    @TableField(exist = false)
    private Integer submitted;

    @TableField(exist = false)
    private Integer should_submitted;

    @TableField(exist = false)
    private String states;

    @TableField(exist = false)
    private String comment;

    @TableField(exist = false)
    private Float code;

    private Double scale;

}
